<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%--采购合同号、含税货款金额、总金额、申请金额、供应商合同号、款项类型、付款基准日、付款申请子项号--%>
<script>
  $(function(){
    var supplierId = $("#supplierId").text();
    $('#memberNoSub').val(supplierId);
    searchFun("/purchase/selectPageContractList.html", $('#contractPayment'), getPaymentContractInfo);

    $('#addPaymentSubFunction').click(function(){
      var rows = $('#contractPayment').datagrid('getChecked');
      selectedRows = rows;
      var subIterms = $('#subItem').datagrid('getRows');
      $.each(selectedRows, function (index, value) {
        var inA = false;
        for (var i = 0; i < subIterms.length; i++) {
          if (subIterms[i].contractCode == value.contractCode) {
            inA = true;
          }
        }
        if (!inA) {
          addRows(value);
        }
      });
      calculatePaymentToTop();
      parent.$.modalSubDialog.handler.dialog('close');
    });
    function addRows(value){
      var appBalance= value.taxGoodsAmount -value.amountPaid - value.amountApplication;
      appBalance = appBalance>0?appBalance:0;
      var row ={
        cid: UUID(),
        f_contractId:value.id,
        contractCode:value.contractCode,
        taxAmount:value.taxGoodsAmount,
        totalAmount:value.taxGoodsAmount -value.amountPaid,
//        appBalance:value.totalAmount -value.amountPaid - value.amountApplication,
        appBalance:appBalance,
        privoderCcode:value.providerContract,
        moneyType:value.moneyType
      }
      $('#subItem').datagrid('appendRow', row);
    }
  });
</script>


<var hidden="hidden" id="supplierId">${supplierId}</var>
<div class="easyui-layout" data-options="fit : true,border : false">
  <div data-options="region:'north',title:'查询条件',border:false" style="height: 100px; overflow: hidden;">
    <form id="searchForm">
      <div class="mTop20 mLeft60">
        <div class="mTop10 line-handsome" >
          <div class="fLeft label-handsome" style="width:180px">
            <label style="width:80px">供应商代码:</label>
            <input id="memberNoSub" name="f_providerId" class="easyui-input" style="width:60px" readonly/>
          </div>
          <div class="fLeft label-handsome" style="width:300px">
            <label style="width:70px">申请日期:</label>
            <input id="appstarttime" name="startDate" class="easyui-datebox" style="width:90px"/>
            &nbsp;-&nbsp;
            <input id="appendtime" name="endDate" class="easyui-datebox" style="width:90px"/>
          </div>
          <div class="fLeft">
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search'"
               onclick="searchFun('/purchase/selectPageContractList.html', $('#contractPayment'), getPaymentContractInfo);">搜索</a>
            <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'brick_delete'"
               onclick="cleanFun();">清空搜索条件</a>
          </div>
        </div>
      </div>
    </form>
  </div>
  <div data-options="region:'center',title:'采购合同列表',border:false">
    <table id="contractPayment"></table>
  </div>
</div>